package com.jck.data.task;

import java.io.File;

import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jck.data.util.KettleExecuUtil;
import com.jck.data.util.QuartzFactoryUtil;
import com.jck.data.util.Times;

public class DataSyncTask implements Job {
	public static Logger logger = LoggerFactory.getLogger(DataSyncTask.class);
	public static String defaultJobName = "DataSyncTask";

	public DataSyncTask() {

	}

	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		JobDataMap dataMap = context.getJobDetail().getJobDataMap();
		String transName = (String) dataMap.get("transName");
		System.out.println("DataSyncTask任务执行时间：" + Times.getTimes() + transName);
		logger.info("DataSyncTask任务执行时间：" + Times.getTimes());

		String fileName = null;
		if (transName != null && !transName.equals("")) {
			fileName = transName.substring(transName.lastIndexOf(File.separator) + 1);
		}
		
		 if (transName.endsWith(".kjb")) {
				logger.info(transName);
				QuartzFactoryUtil.getInstance().removeJobByCalendar(fileName, fileName);
				KettleExecuUtil.getInstance().runJob(transName);
			}
		
	/*	if (transName.endsWith(".ktr")) {
			logger.info(transName);
 			KettleExecuUtil.getInstance().runTrans(transName);
		} else if (transName.endsWith(".kjb")) {
			logger.info(transName);
			QuartzFactoryUtil.getInstance().removeJobByCalendar(fileName, fileName);
			KettleExecuUtil.getInstance().runJob(transName);
		}
*/
	}

}
